package structdef

import (
	"codejy/globalfunc"
	"fmt"
)

func init() {
	globalfunc.RegisterFuncAll("NewFuncDefinition", NewFuncDefinition)
}

type FuncDefinition struct {
	// 函数名
	Name string
	// 函数体
	Body []LineCodeDefinition
	//函数注解
	Annotations map[string]map[string]string
}

// 创建函数定义
func NewFuncDefinition(name string, body []LineCodeDefinition, annotations map[string]map[string]string) *FuncDefinition {
	return &FuncDefinition{Name: name, Body: body, Annotations: annotations}
}

// 从写ToString方法
func (f FuncDefinition) String() string {
	return fmt.Sprintf("[函数名称:%s,函数体:%s,函数注解:%s]", f.Name, f.Body, f.Annotations)
}
